// 日常计划周期类型
// 0：天，1：周，2：月
const dailyPeriodTypeEnu = {
  day: 0,
  week: 1,
  month: 2
};

// 日常计划跳过日期枚举
// 0:星期天，1：星期一，2：星期2，3：星期3，4：星期4，5：星期5，6：星期6
const dailySkipDaysEnu = {
  sunday: 0,
  monday: 1,
  tuesday: 2,
  wednesday: 3,
  thursday: 4,
  friday: 5,
  saturday: 6
};

/**
 *
 *转换日常计划跳过日期
 */
export function coverDailySkipDays(day) {
  if (!day) {
    return;
  }

  const {
    sunday,
    monday,
    tuesday,
    wednesday,
    thursday,
    friday,
    saturday
  } = dailySkipDaysEnu;

  const dayObj = {
    [sunday]: "每周天",
    [monday]: "每周一",
    [tuesday]: "每周二",
    [wednesday]: "每周三",
    [thursday]: "每周四",
    [friday]: "每周五",
    [saturday]: "每周六"
  };

  const dailyArr = day.split(",");
  const coverDailyArr = dailyArr.map(day => dayObj[day]);

  return coverDailyArr.join(",");
}

/**
 *
 *转换日常计划周期类型
 */
export function coverDailyPeriodType(type) {
  const { day, week, month } = dailyPeriodTypeEnu;

  const typeObj = {
    [day]: "天",
    [week]: "周",
    [month]: "月"
  };

  return typeObj[type];
}
